{% extends "base.html" %}
{% block title %}Jobs{% endblock %}
{% block more %}
    <li class="nav-header">Actions</li>
    <li><a href="javascript:void(0)" onclick="createNewItem('job')">Add new job</a></li>
    <li class="nav-header">Help</li>
    <li>Jobs contain triggers and tasks. When a job's trigger executes successfully,
    it will begin executing tasks. The results of the run are saved and can be
    viewed later.
{% endblock %}
{% block content %}
<div id="content">
    <h2>Jobs</h2>
    <table id="jobs" class="table table-striped">
        <tr>
            <th>Status</th>
            <th>Job Name</th>
            <th>Run</th>
            <th>Last Run</th>
        </tr>
    {% for job, info in jobs|dictsort %}
        <tr id="{{job}}Job">
            <td>{% if info.Runs|length > 0 %}
                    {% if info.Runs[-1][1] == "success" %}
                        <i class="icon-question-sign"></i>
                    {% else %}
                        <i class="icon-exclamation-sign"></i>
                    {% endif %}
                {% else %}
                    <i class="icon-question-sign"></i>
                {% endif %}</td>
            <td><a href="/jobs/{{job}}">{{job}}</a></td>
            <td>
                <a href="javascript:void(0)" onclick="addRunFromJobs('/jobs/{{job}}', '{{job}}');">
                    <i class="icon-play"></i>
                </a>
            </td>
            {% if info.Runs|length > 0 %}
            <td><a href="/jobs/{{job}}/{{info.Runs|length}}">{{info.Runs|length}}</a></td>
            {% else %}
            <td></td>
            {% endif %}
        </tr>
    {% endfor %}
    </table>
</div>
{% endblock %}